package com.hpeu_01.day0120.homework;

import java.io.File;
import java.io.IOException;

public class Test01 {
    public static void main(String[] args) {
        recurs(new File("d:/aa"),0);
    }
    /**
     * 递归显示指定目录下的所有内容
     */
    public static void recurs(File dir,int i){
        if (dir==null) return;
        File[] files = dir.listFiles();
        for (File file : files) {
            System.out.println(method(i)+file.getName());
            //调用递归
            if (file.isDirectory()){
                recurs(file,i+1);
            }
        }
    }

    public static String method(int i){
        StringBuilder sb = new StringBuilder("|-");
        for (int j = 0; j <i; j++) {
            sb.append("--");
        }
        return sb.toString();
    }
}
